package ViewPagerLoadData;

import java.util.List;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.android.volley.RequestQueue;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.qf.bean.ViewPagerEntity;

public class ViewPagerLoad
{
	public static void loadData(Context context, final Handler handler,
			String url, RequestQueue queue)
	{
		StringRequest request = new StringRequest(url, new Listener<String>()
		{

			@Override
			public void onResponse(String response)
			{
				Log.i("ViewPagerLoad", "ViewPagerLoad下载下来的数据为:" + response);
				// 解析数据
				List<ViewPagerEntity> datas = ParserViewPagerData
						.parseData(response);

				Log.i("ViewPagerLoad", "ViewPagerLoad解析下来的数据为:" + datas);
				Message msg = Message.obtain();
				msg.obj = datas;
				msg.what = 0;
				handler.sendMessage(msg);

			}
		}, new ErrorListener()
		{

			@Override
			public void onErrorResponse(VolleyError error)
			{
			}
		});
		queue.add(request);
	}
}
